package com.xykj.enterprise.wechat.busi.service.ext;

import com.xykj.enterprise.wechat.bean.ext.BaseResp;
import com.xykj.enterprise.wechat.bean.ext.contacts.department.CreateDepartmentVo;
import com.xykj.enterprise.wechat.bean.ext.contacts.department.DepartmentListVo;
import com.xykj.enterprise.wechat.busi.config.ExtClient;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

@Service
@Slf4j
public class ContactsDepartmentServiceImpl implements ContactsDepartmentService {

    @Autowired
    private ExtClient extClient;

    @Override
    public CreateDepartmentVo createDepartment(String accessToken, HashMap<String, Object> params) {
        Map<String, Object> param = new HashMap<>();
        param.put("access_token", accessToken);
        return extClient.get("CreateDepartment", param, CreateDepartmentVo.class);
    }

    @Override
    public BaseResp deleteDepartment(String accessToken, Integer id) {
        Map<String, Object> param = new HashMap<>();
        param.put("access_token", accessToken);
        return extClient.get("DeleteDepartment", param, BaseResp.class);
    }

    @Override
    public DepartmentListVo departmentList(String accessToken, Integer id) {
        Map<String, Object> param = new HashMap<>();
        param.put("access_token", accessToken);
        param.put("id", id);
        return extClient.get("DepartmentList", param, DepartmentListVo.class);
    }

    @Override
    public BaseResp updateDepartment(String accessToken, HashMap<String, Object> params) {
        Map<String, Object> param = new HashMap<>();
        param.put("access_token", accessToken);
        return extClient.get("UpdateDepartment", param, BaseResp.class);
    }
}
